<template>
	<view>
		<page-head :title="'个人中心'" :headtype="1" :bg="`transparent`"></page-head>
		<view class="topblock">
			<image class="topbg" :src="apifun.serveimg+'statisticsbg.png'" mode=""></image>
			<view class="topmain" :style="{'top':statusheadheight+'px'}">
				<view class="usermsg flex">
					<view class="headimg" @click="uploadhead('headimg')">
						<image v-if="!headimg" :src="apifun.serveimg  +'headimg.png'" mode=""></image>
						<image v-if="headimg" :src="apifun.URLimg + headimg" mode=""></image>
					</view>
					<view class="headmsg">
						<view class="headmsgname">{{ assessusermsg.username }}</view>
						<view class="headmsgphone">{{ assessusermsg.mobile }}</view>
					</view>
				</view>
				<view class="protadmin marginAuto">
					<view class="prottitle" @click="apifun.navigate('/pages/assessor/accountsq')">账号审批记录</view>
					<view class="statisnum flex">
						<view class="statiseach" @click="apifun.navigate('/pages/assessor/accountsq','index=1')">
							<view class="statisnumd">{{ account.wait_audit_count }}</view>
							<view class="statisnumt">待审批</view>
						</view>
						<view class="statiseach" @click="apifun.navigate('/pages/assessor/accountsq','index=2')">
							<view class="statisnumd">{{ account.has_audit_count }}</view>
							<view class="statisnumt">已审批</view>
						</view>
						<view class="statiseach" @click="apifun.navigate('/pages/assessor/accountsq','index=3')">
							<view class="statisnumd">{{ account.refuse_audit_count }}</view>
							<view class="statisnumt">已拒绝</view>
						</view>
					</view>
				</view>
				<view class="protadmin marginAuto">
					<view class="prottitle" @click="apifun.navigate('/pages/assessor/productsq')">产品审批记录</view>
					<view class="statisnum flex">
						<view class="statiseach" @click="apifun.navigate('/pages/assessor/productsq','index=1')">
							<view class="statisnumd">{{ order.wait_audit_count }}</view>
							<view class="statisnumt">待审批</view>
						</view>
						<view class="statiseach" @click="apifun.navigate('/pages/assessor/productsq','index=2')">
							<view class="statisnumd">{{ order.has_audit_count }}</view>
							<view class="statisnumt">已审批</view>
						</view>
						<view class="statiseach" @click="apifun.navigate('/pages/assessor/productsq','index=3')">
							<view class="statisnumd">{{ order.refuse_audit_count }}</view>
							<view class="statisnumt">已拒绝</view>
						</view>
					</view>
				</view>
			</view>
		</view> 
		<view class="quit marginAuto" style="width:600rpx;">
			<uv-button text="退出登录" @click="quitfun()" :customStyle="{
				'background':'#2340FF',
				'color':'#fff',
				'font-size':'30rpx',
				'width':'600rpx',
				'height':'100rpx',
				'border-radius':'20rpx'
			}"></uv-button>
		</view>
		<view class="tabbar flex">
			<view class="tabeach" @click="navigatorr('/pages/assesstab/home')">
				<view class="tabimg">
					<image src="@/static/tabbar/home.png" mode=""></image>
				</view>
				<view class="tabname">首页</view>
			</view>
			<view class="tabeach">
				<view class="tabimg">
					<image src="@/static/tabbar/myactive.png" mode=""></image>
				</view>
				<view class="tabname" style="color: #000;">我的</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusheadheight: uni.getStorageSync('ClientRectTop') + uni.getStorageSync('ClientRectHeight'),
				apifun: this.apifun,
				assessusermsg:{},
				headimg:'',
				account:{},
				order:{}
			};
		},
		methods: {
			initData(){
				this.apifun.unirequest('/auditor/index/getAuditInfo','post',{},(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.account = datas.account;
						this.order = datas.order;
					}else{
						this.apifun.toast(res.msg)
					}
				},true)
			},
			uploadhead(img){
				this.apifun.uploadFileimg((res)=>{
					if(res.code == 200){
						this[img] = res.data.src;
						this.apifun.unirequest('/auditor/index/setUserAvatar','post',{
							avatar:res.data.src
						},(res)=>{
							if(res.code === 200){
								let datas = res.data;
							}else{
								this.apifun.toast(res.msg)
							}
						})
					}
				},this)
			},
			quitfun(){
				uni.showModal({
					title: '退出登录',
					content: '确定要退出登录吗？',
					success: function (res) {
						if (res.confirm) {
							let ClientRect = uni.getStorageSync('ClientRect');
							let ClientRectTop = uni.getStorageSync('ClientRectTop');
							let ClientRectHeight = uni.getStorageSync('ClientRectHeight');
							uni.clearStorageSync();
							uni.setStorageSync('ClientRect', ClientRect);
							uni.setStorageSync('ClientRectTop', ClientRectTop);
							uni.setStorageSync('ClientRectHeight', ClientRectHeight);
							setTimeout(()=>{
								uni.reLaunch({
									url:'/pages/start/login'
								})
							},300)
						} else if (res.cancel) {}
					}
				});
			},
			navigatorr(urls,params){
				this.apifun.navigate(urls)
				// uni.reLaunch({
				// 	url:urls
				// })
			}
		},
		onShow(){
			this.assessusermsg = uni.getStorageSync('assessusermsg');
			this.headimg = this.assessusermsg.avatar;
			this.initData()
		},
	};
</script>

<style scoped lang="scss">
	page {
		background-color: #FAFAFA;
		padding-bottom:50px;
	}
	.topbg {
		position: fixed;
		z-index: 10;
		top: 0;
		left: 0;
		width: 100%;
		height: 470rpx;
	}
	.topmain {
		position: fixed;
		width: 690rpx;
		left: 50%;
		margin-left: -345rpx;
		z-index: 20;
		.usermsg{
			margin-top: 30rpx;
			.headimg{
				width: 112rpx;
				height: 112rpx;
				image{
					width: 112rpx;
					height: 112rpx;
					border-radius: 100rpx;
				}
			}
			.headmsg{
				margin-left: 20rpx;
				line-height: 50rpx;
				.headmsgname{
					margin-top: 10rpx;
					font-size: 30rpx;
					color: #333333;
				}
				.headmsgphone{
					font-size:28rpx;
					color:#666666;
				}
			}
		} 
		.protadmin{
			width: 650rpx;
			padding: 20rpx;
			background-color: #fff;
			margin-top: 28rpx;
			border-radius: 10rpx;
			.prottitle{
				font-size: 30rpx;
				color: #333333; 
				line-height: 50rpx;
				font-weight: 600;
			}
			.statisnum{
				flex: 1;
				padding:40rpx 10rpx;
				background-color: #F6F9FF;
				border-radius: 10rpx;
				margin-top:10rpx;
				justify-content: space-between;
				.statiseach{
					width: 25%;
					text-align: center;
					.statisnumd{
						color: #333333;
						font-size: 32rpx;
						font-weight: 600;
					}
					.statisnumt{
						color:#666666;
						font-size:28rpx;
						margin-top: 20rpx;
					}
				}
			}
		}
	}
	.quit{
		position:absolute;
		bottom:200rpx;
		left: 50%;
		margin-left: -300rpx;
	}
	.tabbar{
		position: fixed;
		z-index: 999;
		width: 100%;
		bottom: 0;
		height: 50px;
		justify-content: space-around;
		background:#fff;
		.tabeach{
			width: 50px;
			height: 50px;
			.tabimg{
				width: 24px;
				height: 24px;
				margin:5px auto 0;
				image{
					width: 24px;
					height: 24px;
				}
			}
			.tabname{
				position: relative;
				font-size: 10px;
				color:#666666;
				line-height: normal;
				margin-top: 3px;
				text-align: center;
			}
		}
	}
</style>